#include "skyController.h"
#include "view/camera/fixed_point_camera.h"
#include "view/skyView.h"
#include <iostream>

SkyController::SkyController(View* view,Model* model)
	:	SceneController(view,model){
}

SkyController::~SkyController(){
}

void SkyController::timer(int value){
	SceneModel& smodel = static_cast<SceneModel&>(*model);
	SceneView& sview = static_cast<SceneView&>(*view);
	FixedPointCamera& camera = static_cast<FixedPointCamera&>(sview.getCamera());
	camera.setFixedPoint(smodel.getHelicopter().getDimensions().center());

	SkyBox& sbox = smodel.getSkyBox();
	Point viewerCenter = getViewerCenter();
	if(smodel.getEnvironState()==SceneModel::STORM_ENVIRON){
		Rain& rain = smodel.getRain();

		Point rainCenter = rain.getDimensions().center();
		float zval  = viewerCenter.x3-rainCenter.x3 + rain.getDimensions().height();
		rain.move(viewerCenter.x1-rainCenter.x1,viewerCenter.x2-rainCenter.x2,zval);
	}

	Point sboxCenter = sbox.getDimensions().center();
	sboxCenter.x3 = 0;
	sbox.move(viewerCenter.x1-sboxCenter.x1,viewerCenter.x2-sboxCenter.x2,0);

	smodel.timer(value);
}
